package com.edu.exam.entity.curriculum.questionbank;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Comment;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 多选题质量评估实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：mc_quality_assessment
 *
 * 根据B-02-03-04多选题管理子模块设计文档实现
 * 管理多选题的质量评估信息，包括各维度评分、改进建议等。
 * 支持质量评估的完整流程管理。
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Table(name = "mc_quality_assessment")
@Comment("多选题质量评估表")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MultipleChoiceQualityAssessment {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 评估唯一标识符
     */
    @NotBlank(message = "评估ID不能为空")
    @Size(max = 50, message = "评估ID长度不能超过50个字符")
    @Column(name = "assessment_id", nullable = false, length = 50, unique = true)
    private String assessmentId;

    /**
     * 关联的多选题ID
     */
    @NotBlank(message = "题目ID不能为空")
    @Column(name = "question_id", nullable = false)
    private String questionId;

    /**
     * 评估类型（AUTOMATED-自动评估，MANUAL-人工评估，HYBRID-混合评估）
     */
    @NotBlank(message = "评估类型不能为空")
    @Size(max = 20, message = "评估类型长度不能超过20个字符")
    @Column(name = "assessment_type", nullable = false, length = 20)
    private String assessmentType;

    /**
     * 评估状态（PENDING-待评估，IN_PROGRESS-评估中，COMPLETED-已完成，APPROVED-已通过，REJECTED-已拒绝）
     */
    @NotBlank(message = "评估状态不能为空")
    @Size(max = 20, message = "评估状态长度不能超过20个字符")
    @Column(name = "assessment_status", nullable = false, length = 20)
    private String assessmentStatus;

    /**
     * 评估者ID
     */
    @Column(name = "assessor_id")
    private Long assessorId;

    /**
     * 评估者姓名
     */
    @Size(max = 50, message = "评估者姓名长度不能超过50个字符")
    @Column(name = "assessor_name", length = 50)
    private String assessorName;

    /**
     * 评估者角色（QUALITY_EXAMINER-质量评估员，SUBJECT_EXPERT-学科专家，SENIOR_TEACHER-高级教师）
     */
    @Size(max = 30, message = "评估者角色长度不能超过30个字符")
    @Column(name = "assessor_role", length = 30)
    private String assessorRole;

    /**
     * 评估时间
     */
    @NotNull(message = "评估时间不能为空")
    @Column(name = "assessment_time", nullable = false)
    private LocalDateTime assessmentTime;

    /**
     * 分配时间
     */
    @Column(name = "assign_time")
    private LocalDateTime assignTime;

    /**
     * 开始评估时间
     */
    @Column(name = "start_time")
    private LocalDateTime startTime;

    /**
     * 完成评估时间
     */
    @Column(name = "complete_time")
    private LocalDateTime completeTime;

    /**
     * 截止时间
     */
    @Column(name = "deadline_time")
    private LocalDateTime deadlineTime;

    /**
     * 总体质量评分（1-5分）
     */
    @Column(name = "overall_score", precision = 3, scale = 2)
    private BigDecimal overallScore;

    /**
     * 内容质量评分（1-5分）
     */
    @Column(name = "content_quality_score", precision = 3, scale = 2)
    private BigDecimal contentQualityScore;

    /**
     * 选项质量评分（1-5分）
     */
    @Column(name = "option_quality_score", precision = 3, scale = 2)
    private BigDecimal optionQualityScore;

    /**
     * 难度适当性评分（1-5分）
     */
    @Column(name = "difficulty_appropriateness_score", precision = 3, scale = 2)
    private BigDecimal difficultyAppropriatenessScore;

    /**
     * 干扰项有效性评分（1-5分）
     */
    @Column(name = "distraction_effectiveness_score", precision = 3, scale = 2)
    private BigDecimal distractionEffectivenessScore;

    /**
     * 评估结果（PASS-通过，FAIL-未通过，REVISION_REQUIRED-需修改）
     */
    @Size(max = 20, message = "评估结果长度不能超过20个字符")
    @Column(name = "assessment_result", length = 20)
    private String assessmentResult;

    /**
     * 评估意见
     */
    @Column(name = "assessment_comment", columnDefinition = "TEXT")
    private String assessmentComment;

    /**
     * 详细评估数据（JSON格式）
     */
    @Column(name = "assessment_details", columnDefinition = "TEXT")
    private String assessmentDetails;

    /**
     * 改进建议
     */
    @Column(name = "improvement_suggestions", columnDefinition = "TEXT")
    private String improvementSuggestions;

    /**
     * 改进优先级（LOW-低，MEDIUM-中，HIGH-高，URGENT-紧急）
     */
    @Size(max = 10, message = "改进优先级长度不能超过10个字符")
    @Column(name = "improvement_priority", length = 10)
    private String improvementPriority;

    /**
     * 质量等级（EXCELLENT-优秀，GOOD-良好，FAIR-一般，POOR-较差，VERY_POOR-很差）
     */
    @Size(max = 20, message = "质量等级长度不能超过20个字符")
    @Column(name = "quality_grade", length = 20)
    private String qualityGrade;

    /**
     * 问题类型列表（JSON格式，格式：["内容问题", "选项问题", ...]）
     */
    @Column(name = "issue_types", columnDefinition = "TEXT")
    private String issueTypes;

    /**
     * 问题严重程度（MINOR-轻微，MODERATE-中等，MAJOR-严重，CRITICAL-严重）
     */
    @Size(max = 20, message = "问题严重程度长度不能超过20个字符")
    @Column(name = "issue_severity", length = 20)
    private String issueSeverity;

    /**
     * 评估标准版本
     */
    @Size(max = 20, message = "评估标准版本长度不能超过20个字符")
    @Column(name = "assessment_standard_version", length = 20)
    private String assessmentStandardVersion;

    /**
     * 自动评分是否启用
     */
    @Column(name = "auto_score_enabled", nullable = false)
    private Boolean autoScoreEnabled;

    /**
     * 自动评分（1-5分）
     */
    @Column(name = "auto_score", precision = 3, scale = 2)
    private BigDecimal autoScore;

    /**
     * 自动评估详情（JSON格式）
     */
    @Column(name = "auto_assessment_details", columnDefinition = "TEXT")
    private String autoAssessmentDetails;

    /**
     * 人工评分权重（0-1）
     */
    @Column(name = "manual_score_weight", precision = 3, scale = 2)
    private BigDecimal manualScoreWeight;

    /**
     * 自动评分权重（0-1）
     */
    @Column(name = "auto_score_weight", precision = 3, scale = 2)
    private BigDecimal autoScoreWeight;

    /**
     * 评估耗时（分钟）
     */
    @Column(name = "assessment_duration_minutes")
    private Integer assessmentDurationMinutes;

    /**
     * 评估置信度（0-1）
     */
    @Column(name = "assessment_confidence", precision = 3, scale = 2)
    private BigDecimal assessmentConfidence;

    /**
     * 评估标签（JSON格式）
     */
    @Column(name = "assessment_tags", columnDefinition = "TEXT")
    private String assessmentTags;

    /**
     * 相关知识点
     */
    @Column(name = "related_knowledge_points", columnDefinition = "TEXT")
    private String relatedKnowledgePoints;

    /**
     * 评估参考标准
     */
    @Column(name = "reference_standards", columnDefinition = "TEXT")
    private String referenceStandards;

    /**
     * 评估历史记录（JSON格式）
     */
    @Column(name = "assessment_history", columnDefinition = "TEXT")
    private String assessmentHistory;

    /**
     * 评估元数据（JSON格式）
     */
    @Column(name = "metadata", columnDefinition = "TEXT")
    private String metadata;

    /**
     * 软删除标识
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted;

    /**
     * 删除时间
     */
    @Column(name = "delete_time")
    private LocalDateTime deleteTime;

    /**
     * 创建人
     */
    @Size(max = 50, message = "创建人长度不能超过50个字符")
    @Column(name = "created_by", nullable = false, length = 50)
    private String createdBy;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新人
     */
    @Size(max = 50, message = "更新人长度不能超过50个字符")
    @Column(name = "updated_by", nullable = false, length = 50)
    private String updatedBy;

    /**
     * 更新时间
     */
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

}